<!--
 * @Description: 生产调度异常处理审批
 * @Author: wangwangwang
 * @Date: 2020-11-18 15:34:16
 * @LastEditors: wangwangwang
 * @LastEditTime: 2021-02-03 11:45:31
-->
<template>
  <div class="pages_content">
    <el-container>
      <el-main style="margin-bottom: 20px; padding: 0;">
        <el-container direction="vertical">
          <FlowHeader :isReadOnly="readOnly" @saveSubmit="handleSubmit(1)" @sendSubmit="handleSubmit(2)" @handleBackEnd="handleSubmit(3)" @handleCC="handleSubmit(4)" @handleAssign="handleSubmit(5)" @handleBackUp="handleSubmit(6)" @handleAssist="handleSubmit(7)" @handleNode="handleSubmit(8)" @handleNodeImage="handleSubmit(9)" @handleCollection="handleSubmit(10)" />
          <el-main class="info">
            <div>
              <el-input v-model="title" class="flow-title" :disabled="readOnly" placeholder="请输入流程标题"></el-input>
            </div>
            <div class="info-top">
              <div class="left">
                <span>单据号码：{{billCode}}</span>
                <span class="text">制单日期：{{billDate}}</span>
              </div>
              <div class="right">
                <span>发起人：{{applyPerson}}</span>
                <span class="text">状态：{{taskTypeText[taskStatus*1]}}</span>
              </div>
            </div>
            <div style="padding-top: 15px;">
              <el-form :inline="true">
                <div class="flex" style="padding:0">
                  <el-form-item label="工程名：">
                    <div>{{data.engineeringName}}</div>
                  </el-form-item>
                  <el-form-item label="订单号：">
                    <div>{{data.orderNo}}</div>
                  </el-form-item>
                  <el-form-item label="产品名称：">
                    <div>{{data.productName}}</div>
                  </el-form-item>
                </div>
                <div style=" font-weight: bold;">运输基本信息：</div>
                <div class="flex" style="padding-top: 15px;">
                  <el-form-item label="运输号：">
                    <div>{{data.code}}</div>
                  </el-form-item>
                  <el-form-item label="车牌号：">
                    <div>{{data.carNo}}</div>
                  </el-form-item>
                  <el-form-item label="生产时间：">
                    <div>{{data.proTime}}</div>
                  </el-form-item>
                </div>
                <div class="flex">
                  <el-form-item label="生产量（方）：">
                    <div>{{data.proNum}}</div>
                  </el-form-item>
                  <el-form-item label="富余量（方）：">
                    <div>{{data.residueNum}}</div>
                  </el-form-item>
                  <el-form-item label="转入量（方）：">
                    <div>{{data.shiftTo}}</div>
                  </el-form-item>
                </div>
                <div class="flex">
                  <el-form-item label="票面量（方）：">
                    <div>{{data.faceValue}}</div>
                  </el-form-item>
                </div>
                <div style=" font-weight: bold;">异常处理信息：</div>
                <div class="flex" style="padding-top: 15px;">
                  <el-form-item label="类型：">
                    <div>{{data.info.exceptionType==1?'转料':data.info.exceptionType==2?'报废':'积鼓'}}</div>
                  </el-form-item>
                </div>
                <div v-if="data.info.exceptionType==1" class="flex">
                  <el-form-item label="站点：">
                    <div>{{data.info.station}}</div>
                  </el-form-item>
                  <el-form-item label="转料量（方）：">
                    <div>{{data.info.turnNum}}</div>
                  </el-form-item>
                  <el-form-item label="接收工程方：">
                    <div>{{data.info.engineering}}</div>
                  </el-form-item>
                </div>
                <div v-if="data.info.exceptionType==1" class="flex">
                  <el-form-item label="运输距离：">
                    <div>{{data.info.distance}}</div>
                  </el-form-item>
                </div>
                <div class="flex">
                  <el-form-item label="备注：">
                    <div>{{data.info.remark}}</div>
                  </el-form-item>
                </div>
              </el-form>
            </div>
            <div class="flows-details">
              <FlowContent ref="flowcontent" :title='title' :showSendVisible="showSendVisible" @handleCancel="handleCancel" @sendCode="sendCode" @handleFinish="handleFinish" @handleBusiness="handleBusiness" />
            </div>
          </el-main>
        </el-container>
      </el-main>
    </el-container>
  </div>
</template>
<script>
import FlowContent from '@/components/WorkFlow/flowContent';
import FlowHeader from '@/components/WorkFlow/flowHeader';
import { getUserInfo } from "@/utils/auth.js";
export default {
  components: {
    FlowContent,
    FlowHeader,
  },
  data() {
    return {
      type: 0,
      title: '生产调度异常处理审批',
      billCode: '',
      billDate: '',
      applyPerson: '',
      taskTypeText: ['发起', '已保存', '审批中', '已完成', '撤销', '不通过'],
      taskStatus: 0,
      readOnly: false,
      showSendVisible: false,
      data: {
        info: {
          exceptionType: null
        }
      }
    }
  },
  methods: {
    handleBusiness() {
      let url = '/icps/system/sign/intelligent/proDispatchLogistics/exception/update_exception'
      if (this.data.exceptionType == null) {
        url = '/icps/system/sign/intelligent/proDispatchLogistics/exception/handler_exception'
      }
      const params = {
        process_success: {
          url,
          data: { ...this.data.info },
          httpMethod: 'post',
        },
        process_failure: ''
      }
      this.showSendVisible = false;
      this.$refs.flowcontent.handleToFlow(params);
    },
    /**
     * @Description: 
     * @Param: 1为保存，2为最后提交
     * @Author: wangwangwang
     * @param {*} type
     */
    handleFinish() {
    },
    handleSubmit(type) {
      const { query } = this.$route;
      if (query.type * 1 === 2 && type === 2 && query.taskType * 1 !== 2) { // 发起流程
        this.showSendVisible = true;
        return
      }
      const data = {
        dataSource: 'sign_smartschedulj',
        dataContent: JSON.stringify({ id: query.id }), // 业务数据
      }
      this.$refs.flowcontent.saveFlows(type, data);
    },
    handleFlowChat() {
      this.$refs.flowcontent.showFlowNode()
    },
    handleCancel() {
      this.showSendVisible = false;
    },
    /**
     * @Description: 回显业务数据
     * @Param: 
     * @Author: wangwangwang
     */
    initFlowsData(data) {
      const { query } = this.$route;
      if (query.type * 1 !== 1) {
        this.title = query.taskName;
      }
      this.billCode = query.receiptNumber;
      this.billDate = query.createTime;
      this.data = data
    },
    sendCode(code) {
      this.billCode = code;
    },
  },
  created() {
    const { query } = this.$route;
    this.titlestatus = Number(query.type)
  },
  mounted() {
    const { query } = this.$route;
    if (query.type * 1 === 1) { // 发起流程
      this.initFlowsData(JSON.parse(query.id));
      this.$refs.flowcontent.initBaseData('sign_smartschedulj');
      this.billDate = new Date().Format('yyyy-MM-dd hh:mm:ss');
      this.applyPerson = getUserInfo().userRealName;
      return
    }
    this.initFlowsData(JSON.parse(JSON.parse(query.dataContent).id));
    this.readOnly = true;
    this.applyPerson = query.createUserName;
    this.taskStatus = query.taskStatus;
  }
}
</script>
<style lang="scss" scoped>
.flex {
  display: flex;
  padding: 0 50px;
  justify-content: space-between;
}
.flows-details {
  margin-top: 20px;
  justify-content: space-around;
}
.info {
  padding: 0 20px;
  background: #fff;
  .info-top {
    font-size: $font_size;
    color: #000000;
    @include discen_al;
    justify-content: space-between;
    height: 50px;
    border-bottom: 1px #e1e5ed solid;
    .left {
      @include discen_al;
    }
    .text {
      margin-left: 60px;
    }
  }
}
.nav_title {
  @include discen_al;
  align-items: flex-end;
  > div {
    width: 4px;
    height: 24px;
    background: $bg_color;
    margin-right: 10px;
  }
  i {
    margin-left: 5px;
  }
  color: $bg_color;
  font-size: 20px;
  font-weight: bold;
}
.dialoginfo {
  padding: 0;
}
.active {
  border-top: 1px #e1e5ed solid;
  border-right: 1px #e1e5ed solid;
  border-left: 1px #e1e5ed solid;
  background: #fff;
}
.dialoginfo-info {
  border-right: 1px #e1e5ed solid;
  border-left: 1px #e1e5ed solid;
  border-bottom: 1px #e1e5ed solid;
}
/*弹窗*/
.dialoginfo-title {
  > div {
    cursor: pointer;
  }
  height: 48px;
  display: flex;
  background: linear-gradient(
    180deg,
    rgba(250, 252, 255, 1) 0%,
    rgba(245, 247, 250, 1) 100%
  );
  .none {
    font-weight: bold;
    height: 48px;
    @include discen;
    width: calc(calc(100% - 1px) / 2);
    border-bottom: 1px solid #e1e5ed;
    > div {
      line-height: 48px;
      border-bottom: 1px rgba(0, 0, 0, 0) solid;
    }
  }
  .center {
    width: 1px;
    height: 48px;
    background: #e1e5ed;
  }
  .active {
    font-weight: bold;
    height: 48px;
    @include discen;
    width: calc(calc(100% - 1px) / 2);
    border-bottom: 1px solid rgba(0, 0, 0, 0);
    > div {
      color: $bg_color;
      line-height: 48px;
      border-bottom: 1px $bg_color solid;
    }
  }
}
.dialoginfo-info {
  padding: 10px 20px;
  overflow: auto;
  height: calc(85vh - 282px);
  .el-select,
  .el-input,
  .el-date-picker {
    width: 100%;
  }
}
.form-title {
  font-size: 18px;
  margin: 10px 0;
  display: flex;
  justify-content: space-between;
}
</style>